package com.david.documentation.web;

import com.david.documentation.web.view.components.FadeOutInfoMessageBehavior;
import com.david.documentation.web.view.pages.*;
import com.david.documentation.web.view.panels.SearchPanel;
import org.apache.wicket.PageParameters;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.FeedbackPanel;

public abstract class BasePage extends WebPage {

    public BasePage() {
        super();
        initGui();
    }

    public BasePage(PageParameters parameters) {
        super(parameters);
        initGui();
    }

    private void initGui() {
       // addHeaderLinks();
		
        add(new FeedbackPanel("feedbackPanel").setMaxMessages(1).setOutputMarkupId(true).setEscapeModelStrings(false));

		add(new FadeOutInfoMessageBehavior("ul.feedbackPanel", 5000));

		add(new BookmarkablePageLink("home", HomePage.class).add(new SimpleAttributeModifier("class",
				(this.getPage() instanceof HomePage ||
				 this.getPage() instanceof SearchResultPage ||
				 this.getPage() instanceof DetailPage) ? "on" : "")));
		add(new BookmarkablePageLink("cat", CategoryPage.class).add(new SimpleAttributeModifier("class", (this.getPage() instanceof CategoryPage) ? "on" : "")));
		add(new BookmarkablePageLink("tag", TagPage.class).add(new SimpleAttributeModifier("class", (this.getPage() instanceof TagPage) ? "on" : "")));
		add(new BookmarkablePageLink("news", NewDokuPage.class).add(new SimpleAttributeModifier("class", (this.getPage() instanceof NewDokuPage) ? "on" : "")));



		add(new SearchPanel("headerSearch"));
    }

    private void addHeaderLinks() {
        add(new BookmarkablePageLink<BasePage>("headerHomePageLink", Application.get().getHomePage()));
        add(new BookmarkablePageLink<BasePage>("headerHomePageLink2", Application.get().getHomePage()));
    }

}
